package edu.nanyang.controller;

import edu.nanyang.domain.StudentInfo;
import edu.nanyang.service.PaperInfoService;
import edu.nanyang.service.StudentAnswerService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
@RequestMapping("/student")

public class ExamController extends BaseController{
    @Resource
    private PaperInfoService paperInfoService;
    @Resource
    private StudentAnswerService studentAnswerService;

    @GetMapping("/exam")
    public String enterExam() {
        StudentInfo studentInfo=(StudentInfo)request.getSession().getAttribute("login_student");
        int result=studentAnswerService.exist(studentInfo.getStudentNum());
        if(result>0){
            request.setAttribute("tip_info", "您已经测试过，不允许再次测试！");
            return "/main";
        }
        request.setAttribute("question_list", paperInfoService.findAll());
        return "/student/index";
    }


}
